package com.example.newbook.controller;

import com.example.newbook.common.JsonResult;
import com.example.newbook.entity.Category;
import com.example.newbook.service.CategoryService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/category")
public class CategoryController {

    @Resource
    private CategoryService categoryService;

    @RequestMapping("/{id}/detail")
    public JsonResult<Category> getCategoryOnly(@PathVariable int id){
        Category category = categoryService.findCategoryById(id);
        return JsonResult.ok(category);
    }
}
